package ar.edu.unlu.sistemas.ws.business;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;

public class PeerWS implements KvmSerializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4672509687069204203L;
	private String id;
	private String address;
	private Integer port;
	private String name;
	private Integer status;
	
	
	public PeerWS() {
		super();
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PeerWS other = (PeerWS) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getAddress() {
		return address;
	}
	public Integer getPort() {
		return port;
	}
	public void setPort(Integer port) {
		this.port = port;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public Object getProperty(int arg0) {
		switch (arg0) {
			case 0:
				return this.getAddress();
			case 1:
				return this.getId();
			case 2:
				return this.getName();
			case 3:
				return this.getPort();
			case 4:
				return this.getStatus();
			default:
				return null;
		}
		
	}
	@Override
	public int getPropertyCount() {
		return 5;
	}
	@Override
	public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
		switch (arg0) {
			case 0:
				arg2.setName("address");
				arg2.setType(PropertyInfo.STRING_CLASS);
				break;
			case 1:
				arg2.setName("id");
				arg2.setType(PropertyInfo.STRING_CLASS);
				break;
			case 2:
				arg2.setName("name");
				arg2.setType(PropertyInfo.STRING_CLASS);
				break;
			case 3:
				arg2.setName("port");
				arg2.setType(PropertyInfo.INTEGER_CLASS);
				break;
			case 4:
				arg2.setName("status");
				arg2.setType(PropertyInfo.INTEGER_CLASS);
				break;
		}	
	}
	@Override
	public void setProperty(int arg0, Object arg1) {
		switch (arg0) {
		case 0:
			this.setAddress((String)arg1);
			break;
		case 1:
			this.setId((String)arg1);
			break;
		case 2:
			this.setName((String)arg1);
			break;
		case 3:
			this.setPort((Integer)arg1);
			break;
		case 4:
			this.setStatus((Integer)arg1);
			break;
	}	
		
	}
	@Override
	public String toString() {
		return "PeerWS [id=" + id + ", address=" + address + ", port=" + port
				+ ", name=" + name + ", status=" + status + "]";
	}
	
}
